package com.atguigu.yygh.oss.controller;

import com.atguigu.yygh.oss.service.FileService;
import com.haust.su.ghyy.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @author haustsusu
 * @create 2023-05-05-19:55
 */
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {

    @Autowired
    private FileService fileService;

    @PostMapping("fileUpload")
    //通过MultipartFile对象获得上传的文件
    public Result fileUpload(MultipartFile file){
        //获取上传的文件
        String url=fileService.upload(file);
        return Result.ok(url);

    }
}
